import 'package:flutter/material.dart';
import '../utils/general.dart';

class FFCartNumber extends StatefulWidget {
  final VoidCallback onPress;
  final String mm ;

  static void ffPlaceholdFun(){

  }

  FFCartNumber({Key key,  this.onPress = ffPlaceholdFun, this.mm = 'jj'}):super(key:key);
  @override
  State<StatefulWidget> createState() {
    return FFCartNumberState();
  }
}

class FFCartNumberState extends State<FFCartNumber> {
  int number = 1;

  ffprint(){
    print('--- $number +++');
  }
  @override
  Widget build(BuildContext context) {
    double scale = widthScale(context);
    return Row(
      mainAxisSize:MainAxisSize.min,
      mainAxisAlignment:MainAxisAlignment.spaceBetween,
      children:[
        GestureDetector(
          onTap: (){
            setState(() {
              number -= 1;   
              widget.onPress();           
            });
          },
          child: SizedBox(
            width:30 * scale,
            height: 30 * scale,
            child: Icon(Icons.remove_circle_outline, color: Color.fromRGBO(136, 175, 213, 1.0), size: 20 * scale,),
          ),),
        SizedBox(
          width:30 * scale,
          height:30 * scale,
          child:Center(
            child:Text(
              '$number',
              style:TextStyle(fontSize: 13 * scale, fontWeight:FontWeight.normal, color:Colors.black45)
            ),
          )
        ),
        GestureDetector(
          onTap: (){
            setState(() {
              number += 1;
              widget.onPress();
            });
          },
          child: SizedBox(
            width:30 * scale,
            height: 30 * scale,
            child: Icon(Icons.add_circle, color: Color.fromRGBO(136, 175, 213, 1.0), size: 20 * scale,),
          ),),
      ]
    );
  }

}
